import { combineReducers } from 'redux';
// reducer是一个函数, 这个函数需要两个参数, state(老的状态数据),action(更新规则, {type:'',data})
// 导入action-types
import { INCREMENT, DECREMENT } from './action-types';
// 计数器reducer
function counter(state = 0, action) {
    switch (action.type) {
        case INCREMENT:
            return state + parseInt(action.data);
            break;
        case DECREMENT:
            return state - parseInt(action.data);
            break;
        default:
            return state;
    }
}

export default combineReducers({
    counter
});